import React, { Component } from 'react'
export default class Comment extends Component {
    _parseTime(time){
        let now = new Date()
        let updateTime = Date.parse(time)
        let timeStamp = now.getTime()
        let showTime = (timeStamp-updateTime)/(1000*60)
        if( showTime > 60 ){
            return Math.ceil(showTime/60)>24?Math.ceil((showTime/60)/24)+'天前':Math.ceil(showTime/60)+'小时前'
        } else {
            return Math.ceil(showTime/60)+'分钟前'
        }
    }
    render(){
        const comment = this.props.comment
        return (
            <div className="hotCommentList clearFix">
                <div className="hotCommentAuthorIcon">
                    <img src={'http://statics.zhuishushenqi.com'+comment.author.avatar} alt='icon'/>
                </div>
                <div className="hotCommentAuthorWord">
                    <div className="hotCommentAuthorName">
                        {comment.author.nickname}
                        <div className="hotCommentPublishTime">
                            {this._parseTime(comment.updated)}
                        </div>
                    </div>
                    <div className="hotCommentTitle">
                        {comment.title}
                    </div>
                    <div className="bookStar">
                        <i className="fa fa-star" aria-hidden="true"></i>
                        <i className="fa fa-star" aria-hidden="true"></i>
                        <i className="fa fa-star" aria-hidden="true"></i>
                        <i className="fa fa-star" aria-hidden="true"></i>
                        <i className="fa fa-star-o" aria-hidden="true"></i>
                    </div>
                    <div className="hotCommentContent">
                        <p style={{with:'100%'}}>
                            {comment.content}
                        </p>
                    </div>
                    <div className="hotCommentContentAgree">
                        <i className="fa fa-thumbs-up" aria-hidden="true"></i>
                        {comment.likeCount}
                    </div>
                </div>
            </div>
        )
    }
}